<template>
  <div>
    <div class="card-container">
      <div class="card-items">
        <div class="card-item" @click="toStore()">
          <div>
            <svg class="icon icon-size" aria-hidden="true">
              <use xlink:href="#icon-_re" />
            </svg>
          </div>
          <span class="title1">门店自取</span>
          <span class="title2">下单免排队</span>
        </div>
        <div class="card-item" @click="toAddress()">
          <div>
            <svg class="icon icon-size" aria-hidden="true">
              <use xlink:href="#icon-_waimai" />
            </svg>
          </div>
          <span class="title1">外卖</span>
          <span class="title2">无接触配送，送喜到家</span>
        </div>
      </div>
      <div class="footer">
        <div class="footer-left">
          <div>
            <img src="../../assets/img/pindan.png" alt />
          </div>
          <span>好友拼单</span>
        </div>
        <span class="footer-right">拼单喝茶，青春有喜</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      isLogin: null,
    };
  },
  computed: {
    storeInfo() {
      return this.$store.getters.storeInfo;
    },
    user() {
      return this.$store.getters.userInfo;
    },
    currentAddress() {
      return this.$store.getters.currentAddress;
    },
  },
  mounted() {
    console.log("card",this.user)
    if (this.user != null) {
      this.isLogin = true;
    } else {
      this.isLogin = false;
    }
  },
  methods: {
    toStore() {
      if (JSON.stringify(this.storeInfo) == "{}") {
        //门店未选择
        this.$router.push("store");
      } else {
        //门店已选择
        this.$store.dispatch("setAction", 1);
        this.$router.push("commodity");
      }
    },
    toAddress() {
      console.log("toAddress",this.isLogin)
      if (this.isLogin) {
        //登录
        if (JSON.stringify(this.currentAddress) == "{}") {
          //地址未选择
          this.$router.push("addressList");
        } else {
          //门店已选择
          this.$store.dispatch("setIsTakeSelf", 0);
          this.$router.push("commodity");
        }
      } else {
        //未登录
        this.$emit("changeShow");
      }
    },
  },
};
</script>

<style scoped>
.card-container {
  position: absolute;
  left: 5%;
  top: 35vh;
  /* bottom: 6.3rem; */
  min-width: 90%;
  min-height: 4rem;
  border-radius: 10px;
  background-color: #fff;
}
.card-items {
  width: 100%;
  /* height: 4rem; */
  height: 23vh;
  display: flex;
  flex-direction: row;
  box-sizing: border-box;
  border-bottom: 1px solid #f9f9f9;
  justify-content: space-around;
}
.card-item {
  width: 45%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.card-item .title1 {
  font-size: 22px;
  font-weight: bold;
  font-family: "PHT_B";
  color: #333;
}
.card-item .title2 {
  /* font-size: 12px; */
  color: #646464;
  margin-top: 0.1rem;
}
.footer {
  width: 100%;
  height: 1.3rem;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  line-height: 1.3rem;
  color: #646464;
}
.footer .footer-left {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  margin-left: 0.5rem;
  min-width: 2.5rem;
  font-size: 16px;
  color: #333;
}
.footer .footer-right {
  margin-right: 0.5rem;
  /* font-size: 14px; */
}
.footer img {
  width: 0.7rem;
  height: 0.7rem;
  margin-top: 0.3rem;
}
.icon-size {
  font-size: 56px;
}
</style>